package com.nba.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.nba.bean.Union;
import com.nba.dao.UnionDao;
import com.nba.util.DBUtil;

public class UnionDaoImpl implements UnionDao {
	
	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public Union selectUnionId(String unionName) {
		String sql  = "SELECT * FROM `union` WHERE union_name= ?";
		List<Union> list = jt.query(sql, new BeanPropertyRowMapper<Union>(Union.class),unionName);
		if(list.size() == 0) {
			return null;
		}else {
			return list.get(0);
		}
	}

}
